<!--
 * @Author: xiawei 1243162387@qq.com
 * @Date: 2024-04-19 08:39:26
 * @LastEditors: xiawei 1243162387@qq.com
 * @LastEditTime: 2024-04-19 21:37:36
-->
<template>
    <div style="text-align: left;">
        <v-md-editor v-model="text" height="500px" @save="save"></v-md-editor>
    </div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import useFile from '../hooks/useFile'
const text = ref('')
const fileName = ref('')
const { getFile, saveFile } = useFile()
const save = (_text: string) => {
    saveFile(fileName.value, _text)
}
const getFileFun = async () => {
    const { result } = await getFile(fileName.value)
    if (result) {
        text.value = result
    }
}
const router = useRoute();
onMounted(() => {
    fileName.value = router.query.file as string
    console.log(router.query.file)
    getFileFun()
})
</script>